package com.tianhaochen.springai.mongo;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.springframework.ai.chat.messages.Message;
import org.springframework.data.annotation.Id;

import java.time.LocalDateTime;
import java.util.Map;

@Getter
@Setter
@ToString
@NoArgsConstructor
public class ChatMessage {
    @Id
    private String id;

    /**
     * 对话ID
     */
    private String conversationId;

    private String messageType;

    private String textContent;

    private Map<String, Object> metadata;

    private LocalDateTime createTime = LocalDateTime.now();

    public ChatMessage(String id, String conversationId, Message message) {
        this.id = id;
        this.conversationId = conversationId;
        this.textContent = message.getText();
        this.messageType = message.getMessageType().name();
        this.metadata = message.getMetadata();
    }
}
